package ${package.ServiceImpl};

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.BeanUtils;
import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import org.springframework.stereotype.Service;

import com.stef.saas.common.base.dto.BaseResult;
import com.stef.saas.common.base.dto.PageResult;
import ${package.DTO}.${entity}PageDTO;
import ${package.DTO}.${entity}DTO;
import ${package.VO}.${entity}VO;

/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @date ${date}
 */
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    @Override
    public BaseResult<Page<${entity}>> pageList${entity}(${entity}PageDTO pageDTO){
        ${entity} ${table.entityPath} = new ${entity}();
        BeanUtils.copyProperties(pageDTO, ${table.entityPath});
        return BaseResult.ok(this.page(new Page(pageDTO.getCurrent(), pageDTO.getSize()), Wrappers.query(${table.entityPath})));
    }

    @Override
    public BaseResult<${entity}> doSave(${entity}DTO dto){
        ${entity} ${table.entityPath} = new ${entity}();
        BeanUtils.copyProperties(dto, ${table.entityPath});
        return BaseResult.ok(${table.entityPath});
    }

    @Override
    public BaseResult<Boolean> doDelete(Integer id){
        this.removeById(id);
        return BaseResult.ok(true);
    }


    @Override
    public BaseResult<${entity}> doUpdate(${entity}DTO dto){
        ${entity} ${table.entityPath} = new ${entity}();
        BeanUtils.copyProperties(dto, ${table.entityPath});
        this.updateById(${table.entityPath});
        return BaseResult.ok(${table.entityPath});
    }

    @Override
    public BaseResult<${entity}> detail(Integer id){
        return BaseResult.ok(this.getById(id));
    }
}
</#if>
